package com.deer.wms.ASN.manage.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.deer.wms.ASN.manage.model.qc.QcTaskCriteria;
import com.deer.wms.ASN.manage.model.qc.QcTaskView;
import com.deer.wms.ASN.manage.service.QcTaskService;
import com.deer.wms.project.root.core.result.Result;
import com.deer.wms.project.root.core.result.ResultGenerator;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : wei
 * @since : 2022-01-13 09:51:41
 **/
@Api(description = "质检任务池api接口")
@RestController
@RequestMapping("/qc/task")
public class QcTaskController {
    @Autowired
    private QcTaskService qcTaskService;

    @GetMapping("/list")
    public Result list(QcTaskCriteria criteria) {
        PageHelper.startPage(criteria.getPageNum(), criteria.getPageSize());
        QueryWrapper<QcTaskView> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<>(2);
        List<QcTaskView> list = qcTaskService.list(qw.allEq(map, false)
                .orderByDesc("batch_name"));
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }
}
